//渲染navbar函数
function navbar(pathname) {
    let arr = [
        {
            path: './run.html',
            title: '跑步',
        },
        {
            path: './ride.html',
            title: '骑行',
        },
        {
            path: './cuorse.html',
            title: '课程训练',
        },
    ]

    let html = `
    ${arr.map(v => {
        return `<a href='${v.path}' class="navitem df aic ${v.path === `./${pathname}.html` && 'active'}">${v.title}</a>`
    }).join('')}
    `
    // 创建一个navbar盒子
    let section = document.createElement('section')
    // 添加样式
    section.className = 'navbar df jcsa aic'
    // 导入htlm
    section.innerHTML = html
    // 添加到body之前
    document.body.prepend(section)
}

// 导出navbar函数
module.exports = navbar